package com.codetci.rabbitmq;

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: zhenzhong.wang@honeywell.com
 * @date: 2019/10/14 2:38 PM
 */
@Configuration
public class RabbitmqFactoryConfig {

  @Autowired
  ConnectionFactory mqFactory;

  //配置消费者监听的容器
  @Bean
  public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(mqFactory);
    factory.setConcurrentConsumers(3);
    factory.setMaxConcurrentConsumers(10);
    //factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);//设置确认模式手工确认
    return factory;
  }
}
